var PATH_PREFIX ="";

function setPathPrefix(path){
	PATH_PREFIX =  path;
}
$(function(){
	$(".progress-icon").each(function(index,obj){
		if(index < $("#prjprcstat").val()){
			$(obj).addClass("active");
		}
	});
	//页面
	$('#singleProductDemand').hide();
	$('#singleProductDetail').show();
	showList();
	initPage();
	
	//饼形图表  
	var pieChartValue = document.getElementById('investChart');
	if(pieChartValue){//判断获取是否为空
		var pieChart = echarts.init(pieChartValue); 
		pieChart.clear();  
		pieChart.showLoading({text: '正在努力的读取数据中...'}); 
		var option = {
			    tooltip: {
			        trigger: 'item',
			        formatter: "{a} <br/>{b}: {c} ({d}%)"
			    },
			    legend: {
			        orient: 'none',
			        x: 'right',
			        y: 'center',
			        data:['个人','中小企业','财务公司','投资公司','中型银行','信托资管产品','小型券商']
			    },
			    series: [
			        {
			            name:'访问来源',
			            type:'pie',
			            radius: ['50%', '70%'],
			            avoidLabelOverlap: true,
			            label: {
			                normal: {
			                    show: false,
			                    position: 'center'
			                },
			                emphasis: {
			                    show: true,
			                    textStyle: {
			                        fontSize: '30',
			                        fontWeight: 'bold'
			                    }
			                }
			            },
			            labelLine: {
			                normal: {
			                    show: false
			                }
			            },
			            data:[
			                {value:1, name:'个人'},
			                {value:20, name:'中小企业'},
			                {value:11, name:'财务公司'},
			                {value:16, name:'投资公司'},
			                {value:48, name:'中型银行'},
			                {value:3, name:'信托资管产品'},
			                {value:1, name:'小型券商'}
			            ]
			        }
			    ]
			};
		
		//图形点击事件
		pieChart.on('click',function(params){
			var actionUrl =  "/scbp/business/invesSecur/investTradeListView.do?prdCode="+$("#prdCode").val()+"&securType=01";
			window.open(actionUrl);
		});
		loadDrugs(pieChart,option);
	}
	
	// 条形图表
	var barChartValue = document.getElementById('customerChart');
	if(barChartValue){
		var barChart = echarts.init(barChartValue); 
		barChart.clear();  
		barChart.showLoading({text: '正在努力的读取数据中...'}); 
		var option2 = {
			    tooltip: {
			        trigger: 'axis',
			        axisPointer: {
			            type: 'shadow'
			        }
			    },
			    grid: {
			        left: '3%',
			        right: '4%',
			        bottom: '3%',
			        containLabel: true
			    },
			    xAxis: {
			        type: 'value',
			        boundaryGap: [0, 0.01],
			        splitNumber: 10,
			        splitLine:{show: false},//去除网格线
			        axisLine: {
	                    lineStyle: {
	                        type: 'solid',
	                        color: '#828282',//左边线的颜色
	                        width:'1'//坐标线的宽度
	                    }
	                }
			    },
			    yAxis: {
			        type: 'category',
			        data: ['产品','机构','个人'],
			        axisLine: {
	                    lineStyle: {
	                        type: 'solid',
	                        color: '#828282',//左边线的颜色
	                        width:'1'//坐标线的宽度
	                    }
	                }
			    },
			    series: [
			        {
			            type: 'bar',
			            data: [13, 64, 80],
			            barWidth: 25,
			            itemStyle: {
			            	normal: {
			                    // 定制显示（按顺序）
			                    color: function(params) { 
			                        var colorList = ['#FFD754','#FEA34A','#64C9F5']; 
			                        return colorList[params.dataIndex] 
			                    }
			                }
			            }
			        }
			    ]
			};
		loadDrugs(barChart,option2);
	}
});

//查询  
function loadDrugs(element,option) {  
	element.setOption(option, true);  
	element.hideLoading();
} 

function showSinglePrdStatus(type){
	var actionUrl = PATH_PREFIX + "goSingleProductStatus.do?prdType="+type;
	window.open(actionUrl);
}

